//
//  RBInvoiceNowCell.m
//  zhongzhenglu
//
//  Created by XL on 2022/8/4.
//

#import "RBInvoiceNowCell.h"
#import "UIView+RBAdd.h"
#import "UIScrollView+RBAdd.h"
#import <Masonry.h>
#import "RBThemeConfig.h"
#import <UIColor+YYAdd.h>
#import <UIView+YYAdd.h>
#import "RanTool.h"

@interface RBInvoiceNowCell()

@property(nonatomic, strong)IBOutlet UIImageView *selectImgView;
@property(nonatomic, strong)IBOutlet UILabel *shopNameL;
@property(nonatomic, strong)IBOutlet UILabel *timeL;
@property(nonatomic, strong)IBOutlet UIImageView *goodsImgView;
@property(nonatomic, strong)IBOutlet UILabel *goodsNameL;
@property(nonatomic, strong)IBOutlet UILabel *goodsOrderNumL;
@property(nonatomic, strong)IBOutlet UILabel *goodsCountL;
@property(nonatomic, strong)IBOutlet UILabel *goodsPriceL;

@property(nonatomic, strong)RBCellModel *cellModel;

@end

@implementation RBInvoiceNowCell

- (void)awakeFromNib {
    [super awakeFromNib];
    [self zoomSubViewsWithSelf];
    [self.selectImgView extendResponseArea];
    [self.selectImgView rbAddTapGesWithTarget:self action:@selector(selectBtnTapped)];
}

- (void)setCellModel:(RBCellModel *)cellModel
{
    _cellModel = cellModel;
    RBInvoiceNowModel *model = cellModel.cellData;
    
    self.shopNameL.text = model.store_name;
    
    self.timeL.hidden = YES;
    
    [self.goodsImgView setImageWithUrl:model.file placeHolder:@"b2.jpg"];
    self.goodsNameL.text = model.goods_name;
    self.goodsOrderNumL.text = [NSString stringWithFormat:@"订单编号：%@", model.order_number];
    self.goodsCountL.text = [NSString stringWithFormat:@"商品数量：%@", model.quantity];
    self.goodsPriceL.text = [NSString stringWithFormat:@"¥ %@", model.total_price];
    
    self.selectImgView.image = model.selected? [self selImg]: [self norImg];
}

- (void)selectBtnTapped
{
    RBInvoiceNowModel *model = self.cellModel.cellData;
    model.selected = !model.selected;
    if (self.cellModel.eventBlock)
    {
        self.cellModel.eventBlock(self.cellModel.cellData);
    }
}

- (UIImage *)selImg
{
    return [UIImage imageNamed:@"addressListDefault"];
}

- (UIImage *)norImg
{
    return [UIImage imageNamed:@"unsel"];
}


@end
